﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace IDE{
    public partial class Console : Form{
        Editor ed;
        public Console(){
            InitializeComponent();
        }
        public Console(Editor ed){
            this.ed = ed;
            InitializeComponent();
        }

        private void Console_FormClosing(object sender, FormClosingEventArgs e){
            ed.Dispose();
        }

        private void txtConsole_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            
            
            string texto=txtConsole.Text;
            if (texto.Contains("^ error")){
                int num = texto.LastIndexOf(':');
                string numLi = texto.Substring(num + 1);
                Line(Convert.ToInt32(numLi));
            }

        }
        public void Line(int line)
        {
            ed.txtCode.Focus();
            int lineNumberToSelect = line;
            int start = ed.txtCode.GetFirstCharIndexFromLine(lineNumberToSelect);
            int length = ed.txtCode.Lines[lineNumberToSelect].Length;
            ed.txtCode.Select(start, length);
        }
    }
}
